<?php

namespace longhu\base;

use longhu\MyQuery;
use longhu\traits\db\BaseOptionsTrait;
use longhu\traits\db\RewriteTrait;
use longhu\traits\db\WithTrait;
use think\Model;
use think\model\concern\SoftDelete;
/**
 * @mixin MyQuery
 */
class BaseModel extends Model
{
    use SoftDelete,BaseOptionsTrait,RewriteTrait,WithTrait;

    protected $createTime = 'created_at';

    protected $updateTime = 'updated_at';
    public $hidden = [];
    protected $deleteTime = 'deleted_at';

    protected $defaultSoftDelete = 0;

    protected $autoWriteTimestamp = true;

    // 分页 Limit
    public const LIMIT = 10;
    // 开启
    public const ENABLE = 1;
    // 禁用
    public const DISABLE = 2;

    public function getFields()
    {
        $fields = $this->field;
        foreach ($fields as $key => $value){
            if(!empty($this->hidden)&& in_array($value,$this->hidden)){
                unset($fields[$key]);
            }
        }
        return $fields;
    }
}